package in.co.codedoc.sql.mapping;

import in.co.codedoc.sql.DBOutputColumnMap;
import in.co.codedoc.sql.SQLStatement;

import java.sql.ResultSet;
import java.sql.SQLException;

public class BooleanBooleanOutputColumnMap extends DBOutputColumnMap
	implements BooleanOutputColumnMap
{
	public static DBOutputColumnMap GetDBOutputColumnMap()
	{
		return new BooleanBooleanOutputColumnMap();
	}
	
	@Override
	public void ReadColumn(int index, ResultSet rs)
		throws SQLException
	{
		v = rs.getBoolean(index);
		
		if(Logger.logger.isDebugEnabled())
		{
			if(index > 1)
			{
				SQLStatement.GetDebugStringBuffer().append(",");
			}
		}
		
		if(rs.wasNull())
		{
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append("<NULL>");
			}
			
			SetWasNull();
		}
		else
		{			
			if(Logger.logger.isDebugEnabled())
			{
				SQLStatement.GetDebugStringBuffer().append(v);
			}
		}
	}
	
	public boolean GetValue()
	{
		return v;
	}
	
	private boolean v;
}
